package com.example.sistemacompras;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ListView;

import com.example.sistemacompras.db.DatabaseHandler;
import com.example.sistemacompras.entity.Client;
import com.example.sistemacompras.entity.Order;
import com.example.sistemacompras.entity.OrderDetail;

public class OrderDetailHistoryActivity extends Activity {
	private DatabaseHandler db;
	private Order mOrder;
	private List<OrderDetail> mOrderDetails;
	private ListView list;
	private CustomCartAdapter adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_order_detail_history);
		db = new DatabaseHandler(getApplicationContext());
		mOrder = db.getOrderById((Integer) getIntent().getExtras().get(
				"order_id"));
		mOrderDetails = new ArrayList<OrderDetail>();
		if (mOrder != null) {
			mOrderDetails = db.getOrderDetailsByOrder(mOrder);
		}
		
		adapter = new CustomCartAdapter(this, mOrderDetails, getResources());
		adapter.notifyDataSetChanged();
		list = (ListView) findViewById(R.id.cart_list_view);
		list.setAdapter(adapter);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.order_history, menu);
		return true;
	}

}
